//
//  NewsTableViewCell1.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/21.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "NewsTableViewCell1.h"

@implementation NewsTableViewCell1

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
        
    }
    
    return self;
}

-(void)setupUI{

    UIImageView *picture = [[UIImageView alloc]init];
    
    self.picture = picture;
    
    [self.contentView addSubview:picture];
    
    picture.image = [UIImage imageNamed:@"icon_default_130x130"];
    
    [picture mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.equalTo(self.contentView).offset(15);
        
        make.bottom.equalTo(self.contentView).offset(-15);
        
        make.width.height.equalTo(@80);
        
    }];
    
    UILabel *titleLabel = [[UILabel alloc]init];
    
    [self.contentView addSubview:titleLabel];
    
    titleLabel.numberOfLines = 2;
    
    titleLabel.text = @"啊啊啊啊啊~真不想写.为什么国庆还有那么久啊!!";
    
    self.titleLabel = titleLabel;
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(picture);
        
        make.left.equalTo(picture.mas_right).offset(15);
        
        make.right.equalTo(self.contentView).offset(-15);
        
    }];
    
    
    UILabel *textLabel = [[UILabel alloc]init];
    
    textLabel.text = @"生活为何总是如此艰难啊啊啊啊啊啊啊啊啊啊啊啊啊";
    
    textLabel.font = [UIFont systemFontOfSize:14];
    
    textLabel.textColor = [UIColor lightGrayColor];
    
    self.MyTextLabel = textLabel;
    
    [self.contentView addSubview:textLabel];
    
    [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.equalTo(titleLabel);
        
        make.top.equalTo(titleLabel.mas_bottom).offset(5);
        
    }];
    
    UILabel *timeLabel = [self addLabelWithTitle:@"5小时前"];
    
    self.timeLabel = timeLabel;
    
    [timeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(textLabel);
        
    }];
    
    UILabel *commentLabel = [self addLabelWithTitle:@"评论:48"];
    
    self.commentLabel = commentLabel;
    
    [commentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(timeLabel.mas_right).offset(15);
        
    }];
    
    
    
}

-(UILabel *)addLabelWithTitle:(NSString *)title{

    UILabel *label = [[UILabel alloc]init];
    
    label.text = title;
    
    label.textColor = [UIColor lightGrayColor];
    
    label.font = [UIFont systemFontOfSize:11];
    
    [self.contentView addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.MyTextLabel.mas_bottom).offset(5);
        
    }];
    
    return label;
}



@end






































































